Xbasic

WORD_CHANGE Function

Syntax

Output_List as C = WORD_CHANGE(C change_word_format,C text[,C separator[,C pattern[,L match_pattern]]])

Arguments

change_word_formatCharacter

Special commands that govern how the data in Input_List is transformed. These commands are:

Command

Description

start_position [, end_position ]

Selects text in the input word from start_position, to end_position. Start_position and end_position can be an expression, or be derived using the $ operator.

$(string)

Returns the position in the string where string occurs.

#

Returns the word number in the input word list

&

Concatenates text

textCharacter

A character string list of words.

separatorCharacter

Default = CR-LF. A character string that delimits the words in Input_List.

patternCharacter

Pattern is an optional filter that can include the * and ? wildcard characters. If each word in the Input_List matches the pattern, then the word is changed.

match_patternLogical

Whether or not the pattern should be matched.

Description

Perform operation across a group of words, if pattern is specified, only change those words matching the pattern.

Discussion

Transforms each word in Input_List into a new word based on a format string.

The commands in the Format_String are the same as are used in owner-draw strings in XDialog.

Examples

dim words as c =<<%str%
Smith,Jenny
Jones,Michelle
Amira,Stone
Krayzelberg,Lawson
%str%

dim format as c = "#&' Firstname: '&$(,)+1&', Lastname: '&1,$(,)-1"

? WORD_CHANGE(format, words, crlf() ) 
= 1 Firstname: Jenny, Lastname: Smith
2 Firstname: Michelle, Lastname: Jones
3 Firstname: Stone, Lastname: Amira
4 Firstname: Lawson, Lastname: Krayzelberg


? WORD_CHANGE("1,$(,)-1",words,crlf() )
= Smith
Jones
Amira
Krayzelberg

? WORD_CHANGE("$(,) + 1,99999",words,crlf() )
= ,Jenny
,Michelle
,Stone
,Lawson

? WORD_CHANGE ("1,3",words,crlf() )
= Smi
Jon
Ami
Kra

? WORD_CHANGE ("$(,) + 1",words,crlf() )
= ,Jenny
,Michelle
,Stone
,Lawson

See Also